package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Function;
import com.xx.pmis.persistence.dao.FunctionDAO;
import com.xx.pmis.services.FunctionService;

public class FunctionServiceImpl implements FunctionService {
	FunctionDAO functionDAO = null;

    public FunctionServiceImpl(FunctionDAO functionDAO) {
		super();
		this.functionDAO = functionDAO;
	}

	// 保存或更新菜单
	public void saveOrUpdateFunction(Function function) throws Exception {
		functionDAO.saveOrUpdate(function);
	}

    // 保存菜单
	public void saveFunction(Function function) throws Exception {
		functionDAO.save(function);
	}
	
    // 删除菜单
	public void deleteFunction(Function function) throws Exception {
		functionDAO.delete(function);
	}
	
	// 根据菜单ID查询该菜单
	public Function getFunctionByFunctionID(int functionID) throws Exception {
		Function function = functionDAO.getFunctionByFunctionID(functionID);
		return function;
	}	

	public List<Function> getAllFunction() throws Exception {
		List<Function> functions = functionDAO.getAllFunction();
		return functions;
	}
	
	public List<Function> getAllParentFunction() throws Exception {
		List<Function> functions = functionDAO.getAllParentFunction();
		return functions;
	}
	public List<Function> getAllFunctionByFunctionParentID(int functionParentID) throws Exception {
		List<Function> functions = functionDAO.getAllFunctionByFunctionParentID(functionParentID);
		return functions;
	}
		

}
